<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>修改日志</title>
    <link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/form.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/blog.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
    <form name="blogForm" id="blogForm" action="<%=path%>/daily/blog/update.t4m" class="form" method="post">
      <s:hidden name="blog.id"/>
      <table id="table-1" class="form-table" cellspacing="0" cellpadding="0">
        <tr>
          <td class="form-left"><span class="form-required">*</span>日期</td>
          <td class="form-right"><input type="text" name="blog.forDate" class="text Wdate" value="<s:date name="blog.forDate" format="yyyy-MM-dd"/>" onclick="new WdatePicker({isShowClear:false,readOnly:true});"/></td>
          <td class="form-left">是否共享</td>
          <td class="form-right"><input type="checkbox" name="blog.isShare" value="T" <s:if test="blog.isShare == @org.team4.constants.StringConstant@TRUE">checked="checked"</s:if>/></td>
        </tr>
      </table>
      <table id="table-2" class="form-table" cellspacing="0" cellpadding="0">
        <tr>
          <td class="form-left">标签</td>
          <td class="form-right">
            <input type="hidden" id="blogTagsValue" name="blog.tags" value="<s:property value="blog.tags"/>,"/><%-- 若未修改标签的话，不加这个","会出问题 --%>
            <s:iterator id="blogTags" value="blogTagsList">
              <div class="tags-rect <s:if test="blog.tags.indexOf(#blogTags.name + '-' + #blogTags.color) >= 0">color-selected</s:if>" style="background-color:<s:property value="#blogTags.color"/>;"><s:property value="#blogTags.name"/></div>
            </s:iterator>
            <div class="add-tags"><a href="javascript:top.blogTags.add();top.WPS['jWindowPanel-<s:property value="windowPanelId"/>'].close();">添加标签</a></div>
          </td>
        </tr>
      </table>
      <div id="group-1" class="form-group">日志内容</div>
      <table class="form-table" cellspacing="0" cellpadding="0">
        <tr>
          <td class="form-content">
            <s:textarea id="contents" name="blog.contents" cssClass="textarea" cssStyle="width:650px; height:240px;"></s:textarea>
          </td>
        </tr>
      </table>
      <input type="hidden" id="result" name="result" value="success"/>
      <s:hidden name="tabId"/>
      <s:hidden name="windowPanelId"/>
      <input type="noIterateFlush" value="T"/>
    </form>
    <script src="<%=path%>/js/tinyMCE/tiny_mce.js" type="text/javascript"></script>
    <script src="<%=path%>/js/core.js" type="text/javascript"></script>
    <script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
    <script src="<%=path%>/js/Validate.js" type="text/javascript"></script>
    <script src="<%=path%>/js/datePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      
      var colors = $('.tags-rect');
      colors.click(function(){
        $(this).toggleClass('color-selected');
        var blogTagsValue = $('#blogTagsValue').val('');
        $('div.color-selected').each(function(){
          blogTagsValue.val(blogTagsValue.val()+$(this).text()+'-'+$(this).css('background-color').toUpperCase()+',');
        });
      });
      
      $('#contents').height($(document.body).height() - $('#table-1').outerHeight() - $('#table-2').outerHeight() - $('#group-1').outerHeight() - 6);
      
      tinyMCE.init({
        // General options
        mode : "exact",
        elements : "contents",
        theme : "advanced",
        language : "zh",
        
        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,fontselect,fontsizeselect,forecolor,|,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,outdent,indent,|,undo,redo,|,code",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_resizing : false,
        theme_advanced_path : false,
        force_br_newlines : true,
        force_p_newlines : false,
        forced_root_block : '',
        theme_advanced_font_sizes : "12px,14px,16px,18px,20px,24px",
    
        // Example content CSS (should be your site CSS)
        content_css : "<%=path%>/css/tinyMCE/content.css"
      });
    });
    
    function writeNextOne() {
      $('#result').val('writeNextOne');
    }
    </script>
  </body>
</html>